#!/bin/ash -efu

opt_check_dir_test1() { # UnitTest
	. ../shell-args

	[ -d "$WORKDIR/dir-644" ] ||
		mkdir -m644 "$WORKDIR/dir-644"
	cd "$WORKDIR"

	expect="$(message "DIR: ./dir-644: directory not available." 2>&1)"
	result="$(opt_check_dir "DIR" "./dir-644" 2>&1)" ||:
	rmdir "dir-644"

	assertEquals "$result" "$result" "$expect"
}

opt_check_dir_test2() { # UnitTest
	. ../shell-args

	[ -d "$WORKDIR/dir-755" ] ||
		mkdir -m755 "$WORKDIR/dir-755"
	cd "$WORKDIR"

	expect="$(readlink -ev ./dir-755 2>&1)" ||:
	result="$(opt_check_dir "DIR" "./dir-755" 2>&1)" ||:
	rmdir "dir-755"

	assertEquals "$result" "$result" "$expect"
}

opt_check_dir_test3() { # UnitTest
	. ../shell-args

	[ -d "$WORKDIR/--help" ] ||
		mkdir -m755 "$WORKDIR/--help"
	cd "$WORKDIR"

	expect="$(readlink -f -- --help 2>&1)" ||:
	result="$(opt_check_dir "DIR" "--help" 2>&1)" ||:
	rmdir -- "--help"

	assertEquals "$result" "$result" "$expect"
}
